#include <iostream>
#include <fstream>
#include <string>
#include "bundle.h"
using std::cout;
using std::endl;


int main(int argc , char* argv[])
{
  if (argc < 3)
  {
    cout << "no enough arguements" << endl;
    return -1; 
  }

  std::string istreamstring = argv[1];
  std::string ostreamstring = argv[2];

  // open and copy the content of istreamstring 
  std::ifstream ifs;
  ifs.open(istreamstring.c_str() , std::ios::binary);
    // get the size of istreamstring 
  ifs.seekg(0 , std::ios::end);
  int size = ifs.tellg();
  ifs.seekg(0 , std::ios::beg);
    // get end 
  std::string body;
  body.resize(size);
  ifs.read(&body[0] , size); // &body[0] is a wonderful code  because if we use c_str we just get a const str but &body[0] can give us a str whihout const 

  std::string packed = bundle::pack(bundle::LZIP , body); // compress in lzip format 

  std::ofstream ofs;
  ofs.open(ostreamstring , std::ios::binary);
  ofs.write(&packed[0] , packed.size());

  ifs.close();
  ofs.close();
  return 0;
}
